<cfcomponent displayname="KronosQueries" output="false">

    <!--- Get Current KRONOS employees --->
    <cffunction name="funcGetCurrentEmployees" returntype="query">
        <cfargument default="-1" name="RosettaID" required="no" />
        
        <cfquery name="qryGetCurrentEmployees" datasource="#Session.DataSource#">
            SELECT ce.*, r.* 
            FROM SCFVM18.WFCSuite.dbo.CURRENT_EMPLOYEES ce INNER JOIN
                Rosetta.dbo.RosettaStone R ON ce.PersonIDNo = r.HRPROD_PersonIDNo
            WHERE r.Disabled = 0 
                <cfif arguments.RosettaID NEQ -1> AND r.RosettaID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.RosettaID#" /> </cfif>
            ORDER BY ce.LastName
        </cfquery> 
        
        <!---<cfquery name="qryGetCurrentEmployees" datasource="#Session.DataSource#">
            SELECT * 
            FROM SCFVM18.WFCSuite.dbo.CURRENT_EMPLOYEES ce INNER JOIN
                Rosetta.dbo.RosettaStone R ON ce.PersonIDNo = r.HRPROD_PersonIDNo
            WHERE r.Disabled = 0 
                <cfif arguments.RosettaID NEQ -1> AND r.RosettaID = <cfqueryparam cfsqltype="cf_sql_integer" value="arguments.RosettaID" /> </cfif>
        </cfquery> --->
        
        <cfreturn qryGetCurrentEmployees />
    </cffunction>
    <!--- Get Current KRONOS employees --->
    
    
    
    <!--- Get ALL KRONOS employees --->
    <cffunction name="funcGetAllEmployees" returntype="query">
        <cfargument default="-1" name="RosettaID" required="no" />
        
        <cfquery name="qryGetCurrentEmployees" datasource="#Session.DataSource#">
            SELECT ce.*, r.* 
            FROM SCFVM18.WFCSuite.dbo.ALL_SCF_EMPLOYEES ce INNER JOIN
                Rosetta.dbo.RosettaStone R ON ce.PersonIDNo = r.HRPROD_PersonIDNo
            WHERE 1=1
                <cfif arguments.RosettaID NEQ -1> AND r.RosettaID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.RosettaID#" /> </cfif>
            ORDER BY ce.LastName
        </cfquery>        
        <cfreturn qryGetCurrentEmployees />
    </cffunction>
    <!--- Get ALL KRONOS employees --->
    
    
    
    <!--- Get Current KRONOS employees BY HR ID --->
    <cffunction name="funcGetCurrentEmployeeByID" returntype="query">
        <cfargument default="-1" name="PersonIdNO" required="no" />
        
        <cfquery name="qryGetCurrentEmployees" datasource="#Session.DataSource#">
            SELECT ce.*, r.* 
            FROM SCFVM18.WFCSuite.dbo.CURRENT_EMPLOYEES ce INNER JOIN
                Rosetta.dbo.RosettaStone R ON ce.PersonIDNo = r.HRPROD_PersonIDNo
            WHERE r.Disabled = 0 
                <cfif arguments.PersonIdNO NEQ -1> AND ce.PersonIdNO = <cfqueryparam cfsqltype="cf_sql_integer" value="#val(arguments.PersonIdNO)#" /> </cfif>
            ORDER BY ce.LastName
        </cfquery> 
        
        <cfreturn qryGetCurrentEmployees />
    </cffunction>
    <!--- Get Current KRONOS employees BY HR ID --->
    
    
    
    <!--- Get NonSCF Employees  --->
    <cffunction name="funcGetAllNonSCFEmployees" returntype="query">
        <cfargument default="-2" name="RosettaID" required="no" />
        
        <cfquery name="qryGetCurrentEmployees" datasource="#Session.DataSourceRosetta#">
            SELECT r.RosettaID, r.UserAccount,r.AD_GUID, r.NonSCFMasterID,r.IVIS_IDX,r.[Disabled], 
                n.[First] AS FirstName, n.[Last] AS LastName, n.Middle AS MiddleName, 
                n.Pref AS PreferredName, n.Display AS DisplayName, n.SSN, n.EMail, 
                n.WPhone AS WorkPhone, n.Company, n.Department, n.Supervisor, t.[Type] AS NonSCFType, NULL AS SupervisorIDNo
            FROM RosettaStone r INNER JOIN
                NonSCFMaster n ON r.NonSCFMasterID = n.ID RIGHT OUTER JOIN
                NonSCFTypes t ON n.TypeID = t.ID
            WHERE <!---r.[Disabled] = 0---> 1=1
                <cfif arguments.RosettaID NEQ -2> AND r.RosettaID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.RosettaID#" /> </cfif>
            ORDER BY n.[Last]
        </cfquery>        
        <cfreturn qryGetCurrentEmployees />
    </cffunction>
    <!--- Get NonSCF Employees  --->
    
    
    
    <!--- Get Filepath --->
    <cffunction name="funcGetFilePath" returntype="query">
        
        <cfquery name="qryGetFilePath" datasource="#Session.DataSource#">
            <!--- scf_GetFilePath --->
            Select 
                Directory 
            from 
                FileLibraryDirectory
        </cfquery> 
        
        <cfreturn qryGetFilePath />
    </cffunction>
    <!--- Get Filepath --->
    
    
    
    <!--- Get File types --->
    <cffunction name="funcGetFileTypes" returntype="query">
        <cfargument default="" name="CategoryID" />
        <cfquery name="qryGetFileTypes" datasource="#Session.DataSource#">
            <!--- scf_GetFiles --->
            Select 
                * 
            from 
                FileTypes
            Where 
                CategoryID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.CategoryID#" />
            Order by 
                Name
        </cfquery> 
        
        <cfreturn qryGetFileTypes />
    </cffunction>
    <!--- Get File types --->
    

    <!--- Get Emp Info by HRProd_PersonIDNo from SCFVM18 WFCSuite --->
    <cffunction name="funcGettPersonsObj" returntype="query">
        <cfargument default="-1" name="PersonIDNo" required="yes" />
        
        <cfquery name="qryGettPersonsObj" datasource="#Session.DataSourceWFCDB#">
            Select 
                *
            From 
                tPersons 
            Where
                PersonIDNo = <cfqueryparam cfsqltype="cf_sql_integer" 
                                value="#ARGUMENTS.PersonIDNo#" />
        </cfquery> 
        
        <cfreturn qryGettPersonsObj />
    </cffunction>
    <!--- Get Emp Info by HRProd_PersonIDNo from SCFVM18 WFCSuite --->
    
    
    
    <!--- Get Term Types--->
    <cffunction name="funcGetPersonCodes" returntype="query">
        <cfargument default="" name="CodeType" />
        
        <cfquery name="qryGetPersonCodes" datasource="#Session.DataSourceWFCDB#">
            <!---scf_SCFVM18_GetPersonCodes 'TT' --->
            Select 
                PersonCodeIDNo, PersonCode 
            From 
                tSY_Person_Codes 
            Where
                1 = 1
                <cfif ARGUMENTS.CodeType NEQ "">
                    AND PersonCodeType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.CodeType#" />
                </cfif>
        </cfquery> 
        
        <cfreturn qryGetPersonCodes />
    </cffunction>
    <!--- Get Term Types--->
    
    
    
    <!--- Get PAY_RATE_FREQUENCY_CODES --->
    <cffunction name="funcGetAF" returntype="query">
        <cfargument default="-1" name="FrequencyID" />
        
        <cfquery name="qryGetAF" datasource="#Session.DataSourceWFCDB#">
            Select 
                AnnualizingFactor
            From 
                tSY_PAY_RATE_FREQUENCY_CODES
            Where 
                PayRateFrequencyCodeDomainIDNo = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FrequencyID#" />
        </cfquery> 
        
        <cfreturn qryGetAF />
    </cffunction>
    <!--- Get PAY_RATE_FREQUENCY_CODES --->
    
    
    <!--- Get Depts --->
    <cffunction name="funcGetDepts" returntype="query">
        <cfargument default="-1" name="ID" type="any" />
        
        <cfquery name="qryGetDepts" datasource="#Session.DataSourceWFCDB#"  cachedwithin="#CreateTimeSpan(0,9,0,0)#">
            Select 
                OrganizationDescription + ' (' + rtrim(OrganizationCode) + ')' as Org, OrgCodeIDNo, OrganizationDescription
            From 
                tOrganizations
            Where 
                OrganizationToEffectDate = <cfqueryparam cfsqltype="cf_sql_date" value="1/1/3000" />
                <cfif ARGUMENTS.ID NEQ -1>
                    AND OrgCodeIDNo = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.ID#" />
                </cfif>
            Order by 
                OrganizationDescription, OrganizationCode       
        </cfquery>  
        
        <cfreturn qryGetDepts />
    </cffunction>
    <!--- Get Depts --->
    
    
    
    <!--- Get SupDept --->
    <cffunction name="funcGetSupDept" returntype="query">
        <cfargument default="" name="PersonIDNo" type="string" />
        
        <cfquery name="qryGetSupDept" datasource="#Session.DataSourceWFCDB#" cachedwithin="#CreateTimeSpan(0,9,0,0)#">
            Select 
                OrgCodeIDNo
            From 
                tPosition_Orgs O Inner Join 
                tPerson_Positions P On P.PositionIDNo = O.PositionIDNo
            Where 
                PersonIDNo = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PersonIDNo#" /> AND 
                PositionToEffectDate = <cfqueryparam cfsqltype="cf_sql_date" value="1/1/3000" />
        </cfquery> 
        
        <cfreturn qryGetSupDept />
    </cffunction>
    <!--- Get SupDept --->
    
    
    
    <!--- Get States --->
    <cffunction name="funcGetStates" returntype="query">
    
        <cfquery name="qryGetStates" datasource="#Session.DataSourceWFCDB#" cachedwithin="#CreateTimeSpan(0,9,0,0)#">
            Select LocalCodeIDNo, LocalCodeAbbreviation
            From tLocal_Codes
            Where LocalCodeType = <cfqueryparam cfsqltype="cf_sql_varchar" value="ST" />
            Order by LocalCodeAbbreviation
        </cfquery>
        
        <cfreturn qryGetStates />
    </cffunction>
    <!--- Get States --->
     
    
    
    
    <!--- Get Phone types --->
    <cffunction name="funcGetPhoneTypes" returntype="query">
    
        <cfquery name="qryGetPhoneTypes" datasource="#Session.DataSourceWFCDB#" cachedwithin="#CreateTimeSpan(0,9,0,0)#">
            Select 
                TypeCodeIdNo, TypeCode
            From 
                tTYPE_CODES
            Where 
                TypeCodeToEffectDate = <cfqueryparam cfsqltype="cf_sql_date" value="1/1/3000" /> AND 
                TypeCodeType = <cfqueryparam cfsqltype='cf_sql_varchar' value='PT' /> AND 
                TypeCodeIdNo <> <cfqueryparam cfsqltype="cf_sql_integer" value='23' />
            Order By 
                TypeCodeIdNo
        </cfquery>
    
            <cfreturn qryGetPhoneTypes />
    </cffunction>
    <!--- Get Phone types --->
    
    
    
    <!--- Get CompTypes --->
    <cffunction name="funcGetCompTypes" returntype="query">
        <cfargument default="-1" name="CompType" required="no" />
        
            <cfquery name="qryGetCompTypes" datasource="#Session.DataSourceWFCDB#"> 
                Select 
                    TypeCode, TypeCodeIDNo
                From 
                    tType_Codes
                Where 
                    TypeCodeToEffectDate = <cfqueryparam cfsqltype="cf_sql_date" value='1/1/3000' /> and 
                    TypeCodeType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.CompType#" />
            </cfquery>
        
        <cfreturn qryGetCompTypes />
    </cffunction>
    <!--- Get CompTypes --->
    
    
    
    <!--- Get Position Info --->
    <cffunction name="funcGetPositionInfo" returntype="query">
        <cfargument default="-1" name="PositionIdNo" type="numeric" required="no" />
        
        <cfquery name="qryGetPositionInfo" datasource="#Session.DataSourceWFCDB#">
            Select 
                C.PositionIDNo, PositionCode, PositionCodeDescription
            From 
                tPosition_Codes C Inner Join (
                    Select 
                        PositionIDNo, Max(PositionToEffectDate) as LastFilled
                    From
                        tPerson_Positions
                    Group by
                        PositionIDNo
                ) X On X.PositionIDNo = C.PositionIDNo 
            Where 
                C.PositionIdNo = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PositionIdNo#" />
        </cfquery>
        
        <cfreturn qryGetPositionInfo />
    </cffunction>
    <!--- Get Position Info ---> 
    
    
    
    
    <!--- Get Position Codes --->
    <cffunction name="funcGetPositionCodes" returntype="query">
        <cfargument default="-1" name="PositionID" type="numeric" required="no" />
        
        <cfquery name="qryGetPositionCodes" datasource="#Session.DataSourceWFCDB#">
            Select 
                PositionIDNo, PositionCode, PositionCodeDescription
            From 
                tPosition_Codes 
            Where 
                PositionIdNo = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PositionID#" />
        </cfquery>
        
        <cfreturn qryGetPositionCodes />
    </cffunction>
    <!--- Get Position Codes  --->
    
    
    
    
    <!--- Get Salary Hourly --->
    <cffunction name="funcGetSalaryHourly" returntype="query">
        <cfargument default="-1" name="SalaryHourlyType" required="no" />
        
        <cfquery name="qryGetSalaryHourly" datasource="#Session.DataSourceWFCDB#">
            Select 
                PersonCodeIDNo as ID, PersonCode
            From 
                tSY_Person_Codes
            Where 
                PersonCodeType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.SalaryHourlyType#" />
                
        </cfquery>
        
        <cfreturn qryGetSalaryHourly />
    </cffunction>
    <!--- Get Salary Hourly --->
    
    
    
    
    <!--- Get Frequency --->
    <cffunction name="funcGetFrequency" returntype="query">
        <cfargument default="-1" name="FrequencyID" type="numeric" required="no" />
        
        <cfquery name="qryGetFrequency" datasource="#Session.DataSourceWFCDB#">
            Select 
                PayRateFrequencyCodeDomainIdNo as ID, PayRateFrequencyCode, AnnualizingFactor
            From 
                tSY_Pay_Rate_Frequency_Codes
            Where 
                <cfif ARGUMENTS.FrequencyID NEQ -1>
                    PayRateFrequencyCodeDomainIdNo = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FrequencyID#" />
                <cfelse>
                    1=1
                </cfif>
        </cfquery>
        
        <cfreturn qryGetFrequency />
    </cffunction>
    <!--- Get Frequency --->
    
    
    
    <!--- Get Workers CompInfo --->
    <cffunction name="funcGetWorkersCompInfo" returntype="query">
        
        <cfquery name="qryGetWorkersCompInfo" datasource="#Session.DataSourceWFCDB#">
            Select *
            From 
                tWCMP_Workers_Compensation_Codes
            Where 
                WorkersCompensationIDNo <> <cfqueryparam cfsqltype="cf_sql_integer" value="-10001" />
            Order by 
                WorkersCompensationCode
        </cfquery>
        
        <cfreturn qryGetWorkersCompInfo />
    </cffunction>
    <!--- Get Workers CompInfo --->
       
    
    
    
    <!--- Get Positions --->
    <cffunction name="funcGetPositions" returntype="query">
        <cfargument default="-1" name="PositionID" type="numeric" />
        
        <cfquery name="qryGetPositions" datasource="#Session.DataSourceWFCDB#">        
            Select distinct PositionIDNo, PositionCode, PositionCodeDescription
            From tPosition_Codes 
            <!--- Requested by HR, 4/18/2008, show all positions, not just open positions--->
            <!---Select C.PositionIDNo, PositionCode, PositionCodeDescription
            From tPosition_Codes C
                Inner Join (
                    Select PositionIDNo, Max(PositionToEffectDate) as LastFilled
                    From tPerson_Positions
                    Group by PositionIDNo
                    Having Max(PositionToEffectDate) < '1/1/3000') X On X.PositionIDNo = C.PositionIDNo --->
            Where PositionCodeToEffectDate = <cfqueryparam cfsqltype="cf_sql_date" value='1/1/3000' />
            <Cfif ARGUMENTS.PositionID NEQ -1>
                AND PositionIDNo  = <cfqueryparam cfsqltype="cf_sql_integer" value='#ARGUMENTS.PositionID#' />
            </Cfif>
            Order by PositionCode
        </cfquery>
        
        <cfreturn qryGetPositions />
    </cffunction>
    <!--- Get Positions --->
    
    
    
    <!--- Get EmpCodes --->
    <cffunction name="funcGetEmpCodes" returntype="query">
        
        <cfquery name="qryGetEmpCodes" datasource="#Session.DataSourceWFCDB#">
            Select EmploymentCode, EmploymentCodeIDNo
            From tEmployment_Codes
            Where EmploymentCodeIDNo > <cfqueryparam cfsqltype="cf_sql_integer" value="0" />
            Order by EmploymentCodeIDNo
        </cfquery> 
        
        <cfreturn qryGetEmpCodes />
    </cffunction>
    <!--- Get EmpCodes --->
    
    
    
    <!--- Get Ethnic Codes --->
    <cffunction name="funcGetEthnicCodes" returntype="query">
        
        <cfquery name="qryGetEthnicCodes" datasource="#Session.DataSourceWFCDB#">
            Select 
                EthnicCode, EthnicCodeIDNo
            From 
                tEthnic_Codes
            Where 
                EthnicCodeToEffectDate = '1/1/3000' and EthnicCodeIDNo <> -10001
            Order by 
                EthnicCode      
        </cfquery>
        
        <cfreturn qryGetEthnicCodes />
    </cffunction>
    <!--- Get Ethnic Codes --->
    
    
    
    <!--- Get Marital Codes --->
    <cffunction name="funcGetMaritalCodes" returntype="query">
        
        <cfquery name="qryGetMaritalCodes" datasource="#Session.DataSourceWFCDB#" cachedwithin="#CreateTimeSpan(0,9,0,0)#">
            Select PersonCode, PersonCodeIDNo
            From tSY_Person_Codes
            Where PersonCodeType = 'MS'
            Order by PersonCode
        </cfquery>
        
        <cfreturn qryGetMaritalCodes />
    </cffunction>
    <!--- Get Marital Codes --->
    
    
    
    
    <!--- Get Gender Codes --->
    <cffunction name="funcGetGenderCodes" returntype="query">
        
        <cfquery name="qryGetGenderCodes" datasource="#Session.DataSourceWFCDB#" cachedwithin="#CreateTimeSpan(0,9,0,0)#">
            Select PersonCode, PersonCodeIDNo
            From tSY_Person_Codes
            Where PersonCodeType = 'GN' and PersonCodeIDNo <> -10153
            Order by PersonCode 
        </cfquery>
        
        <cfreturn qryGetGenderCodes />
    </cffunction>
    <!--- Get Gender Codes --->
    
    
    
    
    <!--- Get Get I9 Codes --->
    <cffunction name="funcGetI9Codes" returntype="query">
        
        <cfquery name="qryGetI9Codes" datasource="#Session.DataSourceWFCDB#" cachedwithin="#CreateTimeSpan(0,9,0,0)#">
            Select PersonCode, PersonCodeIDNo
            From tSY_Person_Codes
            Where PersonCodeType = 'I9'
            Order by PersonCode Desc
        </cfquery>
        
        <cfreturn qryGetI9Codes />
    </cffunction>
    <!--- Get Get I9 Codes --->
    
    
    
    
    <!--- Get Reason Codes --->
    <cffunction name="funcGetReasonCodes" returntype="query">
        <cfargument default="-1" name="ReasonCodeType" type="any" required="yes" />
        
        <cfquery name="qryGetReasonCodes" datasource="#Session.DataSourceWFCDB#">
            Select 
                ReasonCode, ReasonCodeIDNo
            From 
                tReason_Codes
            Where 
                ReasonCodeToEffectDate = <cfqueryparam cfsqltype="cf_sql_date" value='1/1/3000' /> and 
                ReasonCodeType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.ReasonCodeType#" />
        </cfquery>
        
        <cfreturn qryGetReasonCodes />
    </cffunction>
    <!--- Get Reason Codes --->
    
    
    
    <!--- Get PositionInfo --->
    <cffunction name="funcGetPositionCode" returntype="query">
        <cfargument name="PositionID" required="yes" />
                
        <cfquery name="qryGetPositionCode" datasource="#Session.DataSourceWFCDB#">
            Select *
            From 
                tJob_Codes J Inner Join 
                tPosition_Codes P on P.JobCodeIdNo = J.JobCodeIdNo Inner Join 
                tPay_Grade_Codes G on J.PayGradeIdNo = G.PayGradeIDNo
            Where 
                P.PositionIdNo = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.PositionID#" />
        </cfquery>
        
        <cfreturn qryGetPositionCode />
    </cffunction>
    <!--- Get PositionInfo --->
    
    
    
    <!--- Get Relations --->
    <cffunction name="funcGetRelations" returntype="query">
                
        <cfquery name="qryGetRelations" datasource="#Session.DataSourceWFCDB#">
            Select RelationCode, RelationCodeIDNo
            From tRelation_Codes
            Where RelationCodeToEffectDate = <cfqueryparam cfsqltype="cf_sql_date" value='1/1/3000' /> 
            Order by RelationCode
        </cfquery>
        
        <cfreturn qryGetRelations />
    </cffunction>
    <!--- Get Relations --->
    
    
    
    <!--- Create Stored Procedure to create HR Record for employee's emergency contacts --->
    <cffunction name="funcCreateEmployeeEmergencyContact" returntype="any">
        <cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="Thread" required="yes"/>
        
        <Cfset retVal = {} />
        <cfset retVal.HRResult = "" />
        
        <cfset ContactOrder = 1>
        
        <cfloop query="ARGUMENTS.QUERIES.GetEmpECInfo"> 
            
            <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_CreationStep3_EmergencyContact">  
                <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.Thread.NewHRPersonIDNo#" />, <!--- @pintPersonIDNo --->
                <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#" />, <!--- @pdteDOH --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#First#" />, <!--- @pstrFirst --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Last#" />, <!--- @pstrLast --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#RelationID#" />, <!--- @pintRelationID --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#ContactOrder#" />,<!--- @pintContactOrder --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.EMP_ADDRESS_TYPE#" />, <!---@pintAddressTypeID --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Address1#" />, <!--- @pstrAddress1 --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Address2#" />, <!---@pstrAddress2 --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#City#" />, <!--- @pstrCity --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#State#" />, <!--- @pintStateID --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Zip#" />, <!--- @pstrZIP --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#PASSEDIN.USA#" />, <!--- @pintUSAID --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#BASE.DisplayPhone(HomePhone)#" />, <!--- @pstrHomePhone --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#BASE.DisplayPhone(CellPhone)#" />,<!--- @pstrCellPhone --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#BASE.DisplayPhone(WorkPhone)#" />,<!--- @pstrWorkPhone --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#WorkPhoneExt#" />,<!--- @pstrWorkExt --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#PhonePrimaryID#" /> <!---@pintPrimaryPhoneID --->
                <cfprocresult name="ErrorCheck" resultset="1">
            </cfstoredproc>
            
            <cfif ErrorCheck.Error NEQ 0>
                <cfset retVal.HRResult &= "Error creating Emergency Contact record for #First# #Last#.  
                    Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">
                <cfset retVal.Result = ErrorCheck.Error>
            </cfif>
            
            <cfset ContactOrder += 1>
        </cfloop>

        <cfreturn retVal />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee's emergency contacts --->
    
    
    
    
    <!--- Create Stored Procedure to create HR Record for employee's address --->
    <cffunction name="funcCreateEmployeeAddressesPhones" returntype="any">
        <cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="Thread" required="yes"/>
        
        <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_CreationStep2_AddressesPhones">  
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.Thread.NewHRPersonIDNo#" />, <!--- @pintPersonIDNo --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#" />, <!--- @pdteDOH --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.EMP_ADDRESS_TYPE#" />, <!--- @pintAddressTypeID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Address1#" />, <!--- @pstrAddress1 --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Address2#" />, <!--- @pstrAddress2 --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.City#" />, <!--- @pstrCity --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.State#" />, <!--- @pintStateID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Zip#" />, <!--- @pstrZIP --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.USA#" />, <!--- @pintUSAID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.HomePhone#" />, <!--- @pstrHomePhone --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.CellPhone#" />, <!--- @pstrCellPhone --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkPhone#" />, <!--- @pstrWorkPhone --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkPhoneExt#" />, <!--- @pstrWorkExt --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.PhonePrimaryID#" /><!--- @pintPrimaryPhoneID --->
            <cfprocresult name="ErrorCheck" resultset="1">
        </cfstoredproc>

        <cfreturn ErrorCheck />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee's address --->
    
    
    
    
    
    <!--- Create Stored Procedure to create HR Record for employee --->
    <cffunction name="funcCreateEmployee" returntype="any">
        <cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="FORM" required="yes"/>
        
        <cfset AnnualSalary = ARGUMENTS.QUERIES.GetEmpInfo.PayRate * ARGUMENTS.QUERIES.GetAF.AnnualizingFactor />
        
        <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_CreationStep1_CreateEmployee">  
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.DOB#"><!--- @pdteDOB --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#"><!--- @pdteDOH --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.First#"><!--- @pstrFirst --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Last#"><!--- @pstrLast --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.PreferredName#"><!--- @pstrPreferred --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Middle#"><!--- @pstrMI --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.SSN#"><!--- @pstrSSN --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.MaritalStatusID#"><!--- @pintMaritalStatusID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EthnicID#"><!--- @pintEthnicID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.GenderID#"><!--- @pintGenderID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.PositionID#"><!--- @pintPosID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PP_REASON_NEW_HIRE#"><!--- @pintPosReasonID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.SupervisorID#"><!--- @pintSupervisorID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PRIMARY_POS#"><!--- @pintPrimaryPos --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PROMOTION#"><!--- @pintPomotion --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.Exempt#"><!--- @pintExempt --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.SalaryHourlyID#"><!--- @pintSalaryHourlyID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.Seasonal#"><!--- @pintSeasonal --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.HoursPerWeek#"><!--- @pintHrsPerWk --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkersCompID#"><!--- @pintWkrsCompID --->
            <cfprocparam cfsqltype='cf_sql_float' value="#ARGUMENTS.PASSEDIN.COMP_LOCATION_FACTOR#"><!--- @pfltCompLocationFactor --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ACTIVE#"><!--- @pintEmployeeStatusIDNo --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.FullTime#"><!--- @pintFullTime --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.I9_PENDING#"><!--- @pintI9PendingID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ORG_SCF#"><!--- @pintOrgCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EmpCodeID#"><!--- @pintEmploymentCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.I9#"><!--- @pintI9OnFileID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ES_REASON_NEW_HIRE#"><!--- @pintEmploymentStatusReasonID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PS_REASON_NEW_HIRE#"><!--- @pintPayReasonID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.CompTypeID#"><!--- @pintCompTypeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.FrequencyID#"><!--- @pintFrequencyID --->
            <cfprocparam cfsqltype="cf_sql_float" value="#ARGUMENTS.QUERIES.GetEmpInfo.PayRate#"><!--- @pfltPayRate --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetAF.AnnualizingFactor#"><!--- @pintAnnualizingFactor --->
            <cfprocparam cfsqltype="cf_sql_float" value="#AnnualSalary#"><!--- @pfltAnnualSalary --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.BASEPAY#"><!--- @pintBasePay --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.DOLLARS#"><!--- @pintCurrencyID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.NewUserID#"><!--- @pstrNewUserID --->
            <cfprocresult name="NewID" resultset="1">
            <cfprocresult name="ErrorCheck" resultset="2">
        </cfstoredproc>
        
        <cfset retVal = {} />
        <cfset retVal.NewID = NewID /> 
        <cfset retVal.ErrorCheck = ErrorCheck />

        <cfreturn retVal />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee --->
    
    
    
    
    
    <!--- Create Stored Procedure to create HR Record for employee --->
    <cffunction name="funcCreateEmployeeRehire" returntype="any">
        <cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="FORM" required="yes"/>
        
        <cfif ARGUMENTS.QUERIES.GetEmpInfo.SalaryHourlyID EQ -10192>
            <cfset LOCAL.Exempt = -1>
        <cfelse>
            <cfset LOCAL.Exempt = 0>
        </cfif> 
        
        <cfif ARGUMENTS.QUERIES.GetEmpInfo.Seasonal>
            <cfset LOCAL.Seasonal = -1>
        <cfelse>
            <cfset LOCAL.Seasonal = 0>
        </cfif> 
        
        <cfif ARGUMENTS.QUERIES.GetEmpInfo.FullTime>
            <cfset LOCAL.FullTime = -1>
        <cfelse>
            <cfset LOCAL.FullTime = 0>
        </cfif>
        
        <cfset LOCAL.AnnualSalary = ARGUMENTS.QUERIES.GetEmpInfo.PayRate * ARGUMENTS.QUERIES.GetAF.AnnualizingFactor />
        
        <cfset LOCAL.HRSupID = SUPER.SCF_HR_MasterID_to_HRPersonID( ARGUMENTS.QUERIES.GetEmpInfo.SupervisorID ) />
        
        <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_RehireStep1">  
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.CheckRehire.PersonIDNo#"><!---@pintPersonIDNo --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.PositionID#"><!---@pintPosID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PP_REHIRE#"><!---@pintPosStatusID --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#"><!---@pdteHire --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.HRSupID#"><!---@pintHRSupID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PRIMARY_POS#"><!---@pintPrimaryPos --Always (-1) --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PROMOTION#"><!---@pintPromotion --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.Exempt#"><!---@pintExempt --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.SalaryHourlyID#"><!---@pintSalaryHourlyID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.Seasonal#"><!---@pintSeasonal      --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.HoursPerWeek#"><!---@pintHrsPerWk --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkersCompID#"><!---@pintWrksCompID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.COMP_LOCATION_FACTOR#"><!---@pintCompLocFactor --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PS_REHIRE#"><!---@pintPayStatusID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.CompTypeID#"><!---@pintCompTypeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.FrequencyID#"><!---@pintFreqID --->
            <cfprocparam cfsqltype="cf_sql_float" value="#ARGUMENTS.QUERIES.GetEmpInfo.PayRate#"><!---@pfltPayRate --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetAF.AnnualizingFactor#"><!---@pintAnnualizingFactor --->
            <cfprocparam cfsqltype="cf_sql_float" value="#LOCAL.AnnualSalary#"><!---@pfltAnnualSalary --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.BASEPAY#"><!---@pintBasePay --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.DOLLARS#"><!---@pintDollars --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ACTIVE#"><!---@pintActive --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EmpCodeID#"><!---@pintEmploymentCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.FullTime#"><!---@pintFullTime --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.I9#"><!---@pintI9OnFileID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ORG_SCF#"><!---@pintOrgID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ES_REHIRE#"><!---@pintESID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.REHIRE#"><!---@pintAction --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.DOB#"><!---@pdteDOB --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.First#"><!---@pstrFirst --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Last#"><!---@pstrLast --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.MaritalStatusID#"><!---@pintMaritalStatusID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Middle#"><!---@pstrMiddle --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.PreferredName#"><!---@pstrPreferred --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EthnicID#"><!---@pintEthnicCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#VAL(ARGUMENTS.QUERIES.GetEmpInfo.GenderID)#"><!---@pintGenderID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.SSN#"><!---@pstrSSN --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.NewUserID#"><!---@pstrNewUserID --->
            <cfprocresult name="NewID" resultset="1">
            <cfprocresult name="ErrorCheck" resultset="2">
        </cfstoredproc> 
              
        <cfset retVal = {} />
        <cfset retVal.NewID = NewID /> 
        <cfset retVal.ErrorCheck = ErrorCheck />

        <cfreturn retVal />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee --->
    
    
    
    
    
    <!--- Test to see if person is a rehire--->
    <cffunction name="funcCheckRehire" returntype="any">
        <cfargument default="-1" name="SSN"  required="yes"/>
        
        <cfquery name ="qryCheckRehire" datasource="#Session.DataSourceWFCDB#">
            SELECT 
                PersonIDNo 
            FROM 
                tPersons 
            WHERE 
                PersonTaxIDNo = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.SSN#" />
        </cfquery>
        
        <cfreturn qryCheckRehire />
    </cffunction>
    <!--- Test to see if person is a rehire--->
    
    
    
    
    
    <!--- UPDATE Primary Phones --->
    <cffunction name="funcUpdatePrimaryPhones" returntype="any">
        <cfargument default="-1" name="PersonIDNo"  required="yes"/>
        <cfargument default="-1" name="DateOFHire"  required="yes"/>
        
        <cfquery name ="qryUpdateNextServer" datasource="#Session.DataSource#">

            scf_SCFVM18_PrimePhones #ARGUMENTS.PersonIDNo#, 
            '#dateformat(dateadd("d", -1, ARGUMENTS.DateOFHire),"mm/dd/yyyy")#'

        </cfquery>

    </cffunction>
    <!--- UPDATE Primary Phones --->
    
    
    
    
    
    <!--- UPDATE Next Mail Server--->
    <cffunction name="funcUpdateNextServer" returntype="any">
        <cfargument default="-1" name="NextMailServerID"  required="yes"/>
        
        <cfquery name ="qryUpdateNextServer" datasource="#Session.DataSource#">
            Update 
                NextMailServer 
            Set 
                ServerID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.NextMailServerID#" />
        </cfquery>

    </cffunction>
    <!--- UPDATE Next Mail Server--->
    
    
    <!--- INSERT Rosetta Record--->
    <cffunction name="funcCreateRosettaRecord" returntype="any">
        <cfargument default="" name="thread"  required="yes"/>  
        
        <cfquery name="qryCreateRosettaRecord" datasource="#Session.DataSourceRosetta#">                
            <!---scf_CreateRosettaRecord 
            <cfif thread.UserID EQ ''>NULL<cfelse>'#thread.UserID#'</cfif>, 
            <cfif thread.AD_GUID EQ ''>NULL<cfelse>'#thread.AD_GUID#'</cfif>, 
            <cfif thread.HRProdID EQ 0 or thread.HRProdID EQ ''>NULL<cfelse>#thread.HRProdID#</cfif>, 
            <cfif thread.EPAR_ID EQ 0 or thread.EPAR_ID EQ ''>NULL<cfelse>#thread.EPAR_ID#</cfif> - Scott's old stored procedure --->
            
            Insert into RosettaStone (
                UserAccount, AD_GUID, HRProd_PersonIDNo, EPAR_ID, [Disabled]
            )
            Values (
                <cfif ARGUMENTS.thread.UserID NEQ ''><cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.thread.UserID#" /><cfelse>NULL</cfif>, 
                <cfif ARGUMENTS.thread.AD_GUID NEQ ''><cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.thread.AD_GUID#" /><cfelse>NULL</cfif>, 
                <cfif ARGUMENTS.thread.HRProdID NEQ 0 OR ARGUMENTS.thread.HRProdID NEQ ''><cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.thread.HRProdID#" /><cfelse>NULL</cfif>, 
                <cfif ARGUMENTS.thread.EPAR_ID NEQ 0 OR ARGUMENTS.thread.EPAR_ID NEQ ''><cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.thread.EPAR_ID#" /><cfelse>NULL</cfif>, 
                1
            )
            
            SELECT @@Identity AS NewRosettaID
        </cfquery>
        
        <cfreturn qryCreateRosettaRecord />
    </cffunction>
    <!--- INSERT Rosetta Record--->
    
    
    
    
    <!--- INSERT Beneficaries Step3 Employee--->
    <cffunction name="funcStep3InsertBeneficaries" returntype="any">
        <cfargument default="" name="FORM"  required="yes"/>
        
        <cfset retObj = {} />        
        
        <cfquery name="qryStep3InsertBeneficaries" datasource="#Session.DataSource#">                
            Insert Into Contacts 
                (EmployeeID, First, Last, Address1, Address2, City, State, ZIP, HomePhone, CellPhone, WorkPhone, WorkPhoneExt, PhonePrimaryID, Email, RelationID, ContactTypeID)
            Values 
            (
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.EmpID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.First#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Last#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address1#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address2#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.City#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.State#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.ZIP#" />,
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#Replace( ARGUMENTS.FORM.HomePhone, "-", "", "All")#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#Replace( ARGUMENTS.FORM.CellPhone, "-", "", "All")#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#Replace( ARGUMENTS.FORM.WorkPhone, "-", "", "All")#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.WorkPhoneExt#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.PhonePrimaryID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Email#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.RelationID#" />,
                <cfqueryparam cfsqltype="cf_sql_integer" value="1" /> <!---1 Beneficiary, 2 Emergency Contact   --->
             )
                
        </cfquery>
        
        <cfset retObj.FORM = ARGUMENTS.FORM />
        
        <cfreturn retObj />
    </cffunction>
    <!--- INSERT Beneficaries Step3 Employee--->
    
    
    
    
    <!--- INSERT Emergency Contacts Step3 Employee--->
    <cffunction name="funcStep3InsertEmergencyContacts" returntype="any">
        <cfargument default="" name="FORM"  required="yes"/>
        
        <cfset retObj = {} />        
        
        <cfquery name="qryStep3InsertEmergencyContacts" datasource="#Session.DataSource#">                
            Insert Into Contacts 
                (EmployeeID, First, Last, Address1, Address2, City, State, ZIP, HomePhone, CellPhone, WorkPhone, WorkPhoneExt, PhonePrimaryID, Email, RelationID, ContactTypeID)
            Values 
            (
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.EmpID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.First#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Last#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address1#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address2#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.City#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.State#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.ZIP#" />,
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#Replace( ARGUMENTS.FORM.HomePhone, "-", "", "All")#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#Replace( ARGUMENTS.FORM.CellPhone, "-", "", "All")#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#Replace( ARGUMENTS.FORM.WorkPhone, "-", "", "All")#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.WorkPhoneExt#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.PhonePrimaryID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Email#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.RelationID#" />,
                <cfqueryparam cfsqltype="cf_sql_integer" value="2" /> <!---2 Beneficiary, 2 Emergency Contact--->
             )
                
        </cfquery>
        
        <cfset retObj.FORM = ARGUMENTS.FORM />
        
        <cfreturn retObj />
    </cffunction>
    <!--- INSERT Emergency Contacts Step3 Employee--->
    
    
    
    
    <!--- UPDATE KronosHR with Navigator Employee Number--->
    <cffunction name="funcUpdateKronosHR" returntype="any">
        <cfargument default="-42" name="HRProd_PersonIDNo"  required="yes"/>
        <cfargument default="-42" name="EmployeeNumber"  required="yes"/>
        <cfargument default="-42" name="UserID"  required="yes"/>
        
        <cfquery name="qryUpdateKronosHR" datasource="#Session.DataSource#">
             scf_SCFVM18_UpdateKronosHR #ARGUMENTS.HRProd_PersonIDNo#, #ARGUMENTS.EmployeeNumber#, '#ARGUMENTS.UserID#'            
        </cfquery>
    </cffunction>
    <!--- UPDATE KronosHR with Navigator Employee Number--->
    
    
</cfcomponent>